/**
 * @Copyright: Interactive Business Solution Pte Ltd, Singapore
 * @Author: Li Wen, 2007-11-20
 * @Version: 071120.001
 * Model class for tour item, following properties are requried
 * id, packageid, name, cityid, itineraryid, desp, offlineOperator, type, offlineOperator, cityName, country
 */
package com.ibsol.model
{
	import com.ibsol.database.PhotoDAO;
	
	import mx.collections.ArrayCollection;
	
	[Bindable]
	[RemoteClass(alias="com.ibsol.tourix.model.Touritem")]
	public class TourItem
	{
		private var _id:int;
		private var _packageid:int;
		private var _name:String;
		private var _cityid:int;
		private var _cityName:String;
		private var _country:String;
		private var _itineraryid:int;
		private var _type:String;
		private var _desp:String;
		private var _offlineOperator:String;
		private var _updateTime:String;
		private var _sequence:int;
		private var _pairid:String;
		
		private var _photos:ArrayCollection = new ArrayCollection();
		private var photoLoaded:Boolean = false;
		/**
		 * Default constructor of TourItem
		 */
		public function TourItem()
		{
			_id = 0;
			_packageid = 0;
			_itineraryid = 0;
			_name = "";
			_cityid = 0;
			_cityName = "";
			_country = "";
			_type = "";
			_desp = "";
			_offlineOperator = "";
			_updateTime = "";
			_sequence = 0;
			_pairid=""
		}
		
		public function set id(value:int):void{
			this._id = value;
		}
		
		public function set packageid(value:int):void{
			this._packageid = value;
		}
		
		public function set itineraryid(value:int):void{
			this._itineraryid = value;
		}
		
		public function set name(value:String):void{
			this._name = value;
		}
		
		public function set cityid(value:int):void{
			this._cityid = value;
		}
		
		public function set cityName(value:String):void{
			this._cityName = value;
		}
		
		public function set country(value:String):void{
			this._country = value;
		}
		
		public function set type(value:String):void{
			this._type = value;
		}
		
		public function set desp(value:String):void{
			this._desp = value;
		}
		
		public function set offlineOperator(value:String):void{
			this._offlineOperator = value;
		}
		
		public function set updateTime(value:String):void{
			this._updateTime = value;
		}
		
		public function set sequence(value:int):void{
			this._sequence = value;
		}
		
		public function get pairid():String{
			return this._pairid;
		}
		public function set pairid(value:String):void{
			this._pairid=value;
		}
		
		public function get id():int{
			return this._id;
		}
		
		public function get packageid():int{
			return this._packageid;
		}
		
		public function get itineraryid():int{
			return this._itineraryid;
		}
		
		public function get name():String{
			return this._name;
		}
		
		public function get cityid():int{
			return this._cityid;
		}
		
		public function get cityName():String{
			return this._cityName;
		}
		
		public function get country():String{
			return this._country;
		}
		
		public function get type():String{
			return this._type;
		}
		
		public function get desp():String{
			return this._desp;
		}
		
		public function get offlineOperator():String{
			return this._offlineOperator;
		}
		
		public function get updateTime():String{
			return this._updateTime;
		}
		
		public function get sequence():int{
			return this._sequence;
		}
		
		/**
		 * Gets photos according to touritem id and type "TOURITEM"
		 * @param:	null
		 * @return:	Array Collection of photos
		 */
		public function get photos():ArrayCollection
		{
			if(!photoLoaded && id > 0)
			{
				var photoDAO:PhotoDAO = new PhotoDAO();
				photoDAO.loadPhotosByForeignData(id, "TOURITEM",
					function(data:ArrayCollection):void
					{
						if(data)
							_photos = data;
					});
				photoLoaded = true;
			}
			return _photos;
		}
	}
}